package com.itheima.io1.mytest2;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.nio.charset.Charset;

/**
 * @author zhangbaiyan
 * @date 2024-09-22 13:44
 * @description:字节打印流
 * @version:
 */
public class test4 {
    public static void main(String[] args) throws FileNotFoundException {
        //1.创建字节打印流的对象
        PrintStream ps = new PrintStream(new FileOutputStream("a.txt"), true, Charset.forName("UTF-8"));
        //2.写出数据
        ps.println("hello world");//写出+自动刷新+自动换行
        ps.print(true);
        ps.println();
        ps.printf("%s", "world");
        //3.释放资源
        ps.close();

    }
}
